<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui"
      xmlns:ui="http://java.sun.com/jsf/facelets" 
      xmlns:c="http://java.sun.com/jsp/jstl/core">

    <h:head>
        <title>Hilo</title>
    </h:head>
    <h:body>
        <p:growl showDetail="true"/>
        <center>
            <p:layout style="min-width:400px;min-height:200px;max-width:1000px;" id="layout"> 
                <p:layoutUnit position="center">

                    <p:dataTable id="temas" value="#{temaController.tema}" var="tema" emptyMessage="#{msg.no_temas}" >

                        <p:column style="width: 200px;">
                            <f:facet name="header">
                                <h:outputText value="#{msg.perfil}"/>
                            </f:facet> 
                            <h:outputLabel value="#{tema.autor}" escape="false" style="height: 30px;width: 100px;font-size: 15px;font-weight: bold"/>
                            <br/>
                            <h:outputLabel value="#{tema.fecha}" escape="false" style="height: 30px;width: 100px;font-size: 10px;"/>
                        </p:column>
                        <p:column>
                            <f:facet name="header">
                                <h:outputText  value="#{tema.titulo}"/>
                            </f:facet> 
                            <h:outputFormat  value="#{tema.content}" escape="false" style="height: 30px;width: 100px;font-size: 14px;"/>
                        </p:column>
                        
                        <c:if test="${not empty sessionScope.SPRING_SECURITY_CONTEXT.authentication.principal and 
                                      sessionScope.SPRING_SECURITY_CONTEXT.authentication.principal.username eq tema.autor}">
                            <p:column>
                                <f:facet name="header">
                                    <h:outputText  value="Borrar"/>
                                </f:facet>
                                <h:form>
                                    <p:commandLink value="Borrar Tema" action="borrarTema2" ajax="false">
                                        <f:setPropertyActionListener value="#{tema}" target="#{temaController.tema}" />
                                    </p:commandLink>          
                                </h:form>
                            </p:column>
                        </c:if>
                        
                    </p:dataTable> 
                    <p:separator/>
                    <c:if test="${not empty sessionScope.SPRING_SECURITY_CONTEXT.authentication.principal and 
                                      sessionScope.SPRING_SECURITY_CONTEXT.authentication.principal.username eq tema.autor}">
                        <h:form prependId="false" id="temasForm">
                            <h:outputLabel for="tituloTema" value="#{msg.titulo}:" />                 
                            <p:inputText id="tituloTema" value="#{temaController.tema.titulo}"/>
                            <br/><br/>
                            <h:outputLabel for="contenidoTema" /> 
                            <p:editor id="contenidoTema" value="#{temaController.tema.content}"/>                
                            <p:commandButton iconPos="right" value="#{msg.editar_tema}" ajax="false" action="irAEditarTema" />
                        </h:form>
                    </c:if>
                    <center><h:outputLink value="/index.html">#{msg.ir_a_inicio}</h:outputLink></center>
                </p:layoutUnit>
            </p:layout>

        </center>
    </h:body>
</html>